from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

# 初始化Chrome浏览器
driver = webdriver.Chrome()

# 打开百度首页
driver.get("https://www.baidu.com")
driver.maximize_window()

try:
    # 定位搜索输入框
    search_input = driver.find_element(By.ID, "kw")
    print("搜索输入框type属性值：", search_input.get_attribute("type"))

except Exception as e:
    print("获取元素属性值失败：", e)

finally:
    sleep(5)  # 休眠5秒供截图
    driver.quit()